package home

import (
	// "fmt"

	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
)

// IndexController 首页控制器
type IndexController struct {
	// Optionally: context is auto-binded by Iris on each request,
	// remember that on each incoming request iris creates a new UserController each time,
	// so all fields are request-scoped by-default, only dependency injection is able to set
	// custom fields like the Service which is the same for all requests (static binding).
	Ctx iris.Context
}

func (c *IndexController) BeforeActivation(b mvc.BeforeActivation) {
	b.Handle("GET", "/", "Index")
	b.Handle("GET", "/about-us", "AboutUs")
	b.Handle("GET", "/resume", "MyResume")
	b.Handle("GET", "/xianyu", "XianYu")
}

// Index 首页
func (c *IndexController) Index() {
	// 首页之前链接到闲鱼推广站点被阿里云警告域名注册和实际不相符。
	c.Ctx.Redirect("/stocks")
	return

}

// 闲鱼工作室
func (c *IndexController) XianYu() mvc.Result {
	c.Ctx.ViewLayout(iris.NoLayout)
	return mvc.View{
		Name: "index.html",
		Data: iris.Map{"Title": "首页"},
	}
}

// AboutUs 关于我们
func (c *IndexController) AboutUs() mvc.Result {
	return mvc.View{
		Name: "about-us.html",
		Data: iris.Map{"Title": "关于我们"},
	}
}

// MyResume 我的简历
func (c *IndexController) MyResume() mvc.Result {
	c.Ctx.ViewLayout(iris.NoLayout)
	return mvc.View{
		Name: "resume.html",
	}
}
